package com.ww.springboot.boot.rxjava;

import io.reactivex.Observable;
import io.reactivex.ObservableOnSubscribe;
import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;

/**
 * 描述：
 *
 * @author 🧑 ‍wanwei
 * @since 2022-04-25 16:35
 */
public class RxJavaDemo2 {

    public static void main(String[] args) {
        Observable observable = Observable.just(1, 2, 3, 4);

        Observer observer = new Observer() {
            @Override
            public void onSubscribe(Disposable d) {
                System.out.println("订阅: " + d);
            }

            @Override
            public void onNext(Object o) {
                System.out.println("next: " + o);
            }

            @Override
            public void onError(Throwable e) {
                e.printStackTrace();
            }

            @Override
            public void onComplete() {
                System.out.println("onComplete");
            }
        };
        observable.subscribe(observer);

    }
}
